﻿function Hero() {
    this.left = 300;
    this.bottom = 60; //--
    this.width = 50;
    this.height = 50;

    this.hero = document.createElement("div");
    this.hero.id = "ball";
    this.hero.style.bottom = this.bottom + "px";
    this.hero.style.left = this.left + "px";
    this.hero.style.width = this.width + "px";
    this.hero.style.height = this.height + "px";
    this.center = { LX: this.left + this.width / 2 - 15, RX: this.left + this.width / 2 + 15, Y: this.bottom};
    this.inBounce = false;

    this.move = function (horizontalDirection, verticalDirection) {
        var botString = this.hero.style.bottom.substr(0, this.hero.style.bottom.length - 2);
        this.bottom = parseInt(botString);
        this.bottom += verticalDirection;
        this.hero.style.bottom = this.bottom + "px";
        this.center.Y = this.bottom; 

        var leftString = this.hero.style.left.substr(0, this.hero.style.left.length - 2);
        this.left = parseInt(leftString);
        this.left += horizontalDirection;
        this.hero.style.left = this.left + "px";
        this.center.LX = this.left + this.width / 2 - 15;
        this.center.RX = this.left + this.width / 2 + 15;
    };
}